﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <link rel="stylesheet" href="~/static/layui/css/layui.css" />
    <title>Register</title>
    <script src="~/static/layui/layui.js"></script>
</head>
<body>
    <fieldset class="layui-elem-field layui-field-title"
        style="margin-top: 20px;">
        <legend>用户信息注册页面</legend>
    </fieldset>
    <form class="layui-form" action="RegPost" method="post">
        <div class="layui-form-item">
            <label class="layui-form-label"><i>*</i>用户名</label>
            <div class="layui-input-inline">
                <input type="text" name="username" required placeholder="请输入用户名"
                    autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><i>*</i>邮箱</label>
            <div class="layui-input-inline">
                <input type="text" name="email" required placeholder="请输入邮箱"
                    autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><i>*</i>手机</label>
            <div class="layui-input-inline">
                <input type="text" name="mobile" required placeholder="请输入手机"
                    autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><i>*</i>密码</label>
            <div class="layui-input-inline">
                <input type="password" name="password" required placeholder="******"
                    autocomplete="off" class="layui-input">
            </div>
        </div>
         <div class="layui-form-item">
            <label class="layui-form-label"><i>*</i>确认密码</label>
            <div class="layui-input-inline">
                <input type="password" name="password" required placeholder="******"
                    autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-filter="formReg" lay-submit>立即提交</button>
                <button class="layui-btn layui-btn-primary" type="reset">重置</button>
            </div>
        </div>
    </form>
     <script type="text/javascript">
         layui.define('form', function (exports) {
             var $ = layui.jquery, layer = layui.layer, form = layui.form;
             form.on('submit(formReg)', function (data) {
                 var _form = $(this).parents('form');
                 layer.msg('数据提交中...', { time: 500000 });
                 $.ajax({
                     type: "POST",
                     url: _form.attr('action'),
                     dataType: 'json',
                     data: _form.serialize(),
                     success: function (res) {
                         console.log(res);
                         layer.msg(res.msg, {}, function () {
                             if (res.code == 1) {
                                 if (typeof (res.url) != 'undefined' && res.url != null && res.url != '') {
                                     location.href = res.url;
                                 } else {
                                     location.reload();
                                 }
                             } else {
                                 location.reload();
                             }
                         });
                     }
                 });
                 return false;
             });
         });
    </script>
</body>
</html>
